package com.gzw.scm.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.gzw.scm.R;
import com.gzw.scm.bean.BMInfo;

import java.util.ArrayList;
import java.util.List;

import static android.R.id.list;
import static com.gzw.scm.adapter.ZZXFPAdapter.getIsSelected;

/**
 * Created by Administrator on 2017/5/4.
 */

public class SelectAdapter extends BaseAdapter{
    // 上下文
    private Context context;
    // 用来导入布局
    private List<BMInfo> list=new ArrayList<>();


    public SelectAdapter(List<BMInfo> list,Context context){
        this.list=list;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            // 获得ViewHolder对象
            holder = new ViewHolder();
            // 导入布局并赋值给convertview
            convertView = View.inflate(context,R.layout.item_select, null);
            holder.tv_mc = (TextView) convertView.findViewById(R.id.tv_mc);
            // 为view设置标签
            convertView.setTag(holder);
        } else {
            // 取出holder
            holder = (ViewHolder) convertView.getTag();
        }
        BMInfo bmInfo = list.get(position);
        holder.tv_mc.setText(bmInfo.getName());
        return convertView;
    }

    public static class ViewHolder {
        public TextView tv_mc;

    }
}
